using System;
using JetBrains.Annotations;
using UnityEngine;

namespace Voodoo.Sauce.Internal.IntegrationCheck
{
	public class IntegrationCheckMessage
	{
		public enum Type
		{
			WARNING = 0,
			ERROR = 1
		}

		public readonly Type type;

		public readonly bool isBackToSettingsBtnDisplayed;

		private readonly string _description;

		[CanBeNull]
		private readonly string[] parameters;

		public string Description
		{
			get
			{
				if (_description != null)
				{
					if (parameters != null)
					{
						try
						{
							string description = _description;
							object[] args = parameters;
							return string.Format(description, args);
						}
						catch (FormatException)
						{
							Debug.LogError("Error when formatting this IntegrationCheckMessage.");
							return "";
						}
					}
					return _description;
				}
				Debug.LogError("No description assigned to this IntegrationCheckMessage.");
				return "";
			}
		}

		public IntegrationCheckMessage(Type type, string description, string[] parameters = null, bool isBackToSettingsBtnDisplayed = false)
		{
			this.type = type;
			_description = description;
			this.parameters = parameters;
			this.isBackToSettingsBtnDisplayed = isBackToSettingsBtnDisplayed;
		}
	}
}
